<template>
    <view>
        <view v-for="(goods, index) in getnoticelist" :key="index">
            <view class="goods_item" @tap="handletap" :id="goods.id">
                <view>
                    <image class="img" src="https://xxzhang.oss-cn-hangzhou.aliyuncs.com/%E5%85%AC%E5%91%8A2.png"></image>
                    <text class="name">{{ goods.noticeTitle }}</text>
                </view>
                <view class="noticetime">
                    <text class="time">{{ goods.time }}</text>
                </view>
            </view>
        </view>
    </view>
</template>

<script>
// pages/notice/notice.js
const app = getApp();
var urlPrefix = app.globalData.urlPrefix;
export default {
    data() {
        return {
			token:null,
            getnoticelist: [],

            goods: {
                id: '',
                noticeTitle: '',
                time: ''
            }
        };
    }
    /**
     * 生命周期函数--监听页面加载
     */,
    onLoad(options) {
        let that = this;
		var token = uni.getStorageSync('token');
		this.token = token
        //公告
        uni.request({
            url: urlPrefix + '/api/applet/index/noticeList',
            method: 'GET',
            header: {
                'content-type': 'application/json',
                'token':this.token
            },
            success: function (res) {
                let dataList = res.data;
                that.setData({
                    getnoticelist: dataList.datas
                });
            }
        });
    },
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady() {},
    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {},
    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide() {},
    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload() {},
    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh() {
		uni.stopPullDownRefresh();  //停止刷新            
	},
    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom() {},
    /**
     * 用户点击右上角分享
     */
    onShareAppMessage() {},
    onShareTimeline(res) {
        // 分享到朋友圈
        return {};
    },
    methods: {
        handletap: function (res) {
            uni.navigateTo({
                url: '/pages/noticetext/noticetext?id=' + res.currentTarget.id
            });
        }
    }
};
</script>
<style lang="scss">
@import './notice.scss';
</style>
